import request from '@/router/axios';

/* OSS 文件上传 公共 */
export const uploadPublic = (file) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: '/api/blade-resource/oss/endpoint/put-file-attach',
    method: 'post',
    data: formData
  })
}

/* OSS 文件上传 私有 */
export const uploadPrivate = (file) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: '/api/blade-resource/oss/endpoint/put-file-private',
    method: 'post',
    data: formData,
  })
}

/* OSS 文件上传 私有上传返回的link可直接访问图片，连接时效10分钟 */
export const uploadPrivateUrl = (file) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: '/api/blade-resource/oss/endpoint/put-file-private_url',
    method: 'post',
    data: formData
  })
}

/**
 * @func OCR服务商文件上传
 * @desc OCR 文件上传 OCR识别
 * @param {String} type - 1身份证人像面 2身份证国徽面 3银行卡 4开户证明 5营业执照
 * */
 export const uploadServiceOCRCard = (file, type) => {
  const formData = new FormData();
  formData.append('file', file);
  formData.append('type', type);
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: '/api/rb-service/service/serviceinfo/service_info/ocrCard',
    method: 'post',
    data: formData
  })
}

/**
 * @func OCR商户文件上传
 * @desc OCR 文件上传 OCR识别
 * @param {String} type - 1身份证人像面 2身份证国徽面 3银行卡 4开户证明 5营业执照
 * */
export const uploadOCRCard = (file, type) => {
  const formData = new FormData();
  formData.append('file', file);
  formData.append('type', type);
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: '/api/rb-service/service/posinfo/pos_info/ocrCard',
    method: 'post',
    data: formData
  })
}
